<?php
/* 
 * Copyright (c) 2018-2021   All rights reserved.
 * 
 * 创建时间：2021-05-15 15:39
 *
 * 项目：upload  -  $  - form.php
 *
 * 作者：liwei 
 */
?>


<div class="page page-formb">
    <div class="navbar page-admin-navbar adminbar navbar-bgcolor-red">
        <div class="navbar-inner">
            <div class="left">
                <a class="link tooltip-init" href="javascript:window.history.back();" data-tooltip="后退">
                    <svg class="icon" aria-hidden="true"><use xlink:href="#fa-back"></use></svg>
                </a>
                <a class="link tooltip-init" href="javascript:window.location.reload();" data-tooltip="刷新">
                    <svg class="icon" aria-hidden="true"><use xlink:href="#fa-refresh"></use></svg>
                </a>
                <a class="link">
                    <label for="dosubmit">
                        <svg class="icon" aria-hidden="true"><use xlink:href="#fa-save"></use></svg>
                    </label>
                </a>
            </div>
            <div class="title">
                <?php echo Lev::$app['title']?>
                <tips class="date" style="color:red !important;"></tips>
            </div>
            <div class="right">
            </div>
        </div>
    </div>

    <div class="page-content">
        <div class="form-mainb">
            <form id="saveForm" class="card" action="" method="post">

                <?php echo \lev\widgets\inputs\inputsWidget::form($inputs, $inputsValues, 'module')?>

                <div class="card-footer">
                    <button type="submit" id="dosubmit" class="button-fill button wd100 dosaveFormBtn">
                        <svg class="icon" aria-hidden="true"><use xlink:href="#fa-save"></use></svg>
                        保 存
                    </button>
                    <div>
                        <label>
                            <input type="checkbox" name="generateAdminFiles" value="1">
                            <tips>勾选后，为【数据表】创建控制器文件（自动生成）强制生成也需要勾选</tips>
                        </label>
                        <div><label>
                                <?php if (\modules\levmodules\helpers\generateHelper::isExistIden($idenDir = \lev\helpers\ModulesHelper::getIdenDir($inputsValues['identifier']))):?>
                                    <input type="checkbox" name="generateFiles" value="1">
                                    <tips>模块文件目录已经创建:<?php echo Lev::$aliases['@modules']?>/<?=$idenDir?></tips>
                                <?php else:?>
                                    <input type="checkbox" name="generateFiles" value="1" checked>
                                    <tips>创建模块文件到目录:<?php echo Lev::$aliases['@modules']?>/唯一标识</tips>
                                <?php endif;?>
                            </label>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>

</div>

<script>
    (function () {
        'use strict';

        jQuery(function () {
            formForm.init();
        });

        var formForm = {
            init:function () {
                Levme.onClick('.dosaveFormBtn', function () {
                    return formForm.dosaveForm();
                });


            },
            dosaveForm:function () {
                showIconLoader(true);
                jQuery('form#saveForm').ajaxSubmit({
                    url: '',
                    data: {dosubmit:1, _csrf:_csrf, inajax:1, _:Math.random()},
                    type:'post',
                    dataType: 'json',
                    success: function(data){
                        hideIconLoader();
                        if (parseInt(data.status) >0) {
                            levtoast(data.message);
                            window.setTimeout(function () {
                                window.location = window.location;
                            }, 400);
                        }else if (data && data.message) {
                            levtoast(data.message, 15000);
                        }
                        showFormErrors(data.errors);
                    },
                    error: function(data) {
                        hideIconLoader();
                        errortips(data);
                    }
                });
                return false;
            },
        };

    })();
</script>


